/*
 * SolarTrackActivity.h
 *
 *  Created on: 2022年03月08日
 *      Author: vicent-PC
 */

#include "./websocket/WebSocketService.h"
#include "Activity.h"
#include "Canvas.h"
#include "WebService.h"
#include "power_track/Ina226App.h"
#include "SystemServer.h"

#ifndef MAIN_ROSE_APP_SolarTrackActivity_H_
#define MAIN_ROSE_APP_SolarTrackActivity_H_
class SolarTrackActivity : public Activity {
 public:
    static constexpr const char* APPNAME = "Solar";
    static SolarTrackActivity* getInstance() {
        if (m_pInstance == nullptr) m_pInstance = new SolarTrackActivity();
        return m_pInstance;
    }
    SolarTrackActivity() {};
    virtual ~SolarTrackActivity() {};
    virtual void onCreate();
    virtual void onEvent();
    virtual void onDraw();
 private:
    float initPwm100();
    int calLuxIdx();
    float setPwm2IVP(float &cur, float &vol, float &power, int PWM, int sleepTimeMs);
 public:
    bool mWifiConnected = false;
    uint32_t mIp = 0;
    char mIpStr[32] = {0};
    static SolarTrackActivity * m_pInstance;
 private:
    View* mView = nullptr;
    Canvas* mCanvas = nullptr;

    WebSocketService* mWebSocketServer = nullptr;
    Ina226App mInaApp;
    bool mInaAppInited = false;
    int mConvStarted = 3;
    float mConvPWM = 0.0;
};
#endif
